<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>siblings</title>
    <script src="../jquery-3.4.1.js"></script>
    <style>
        .left {
            width: auto;
            height: 150px;
        }
        .left div {
            width: 150px;
            height: 100px;
            padding: 5px;
            margin: 5px;
            float: left;
            background: #bbffaa;
            border: 1px solid #ccc;
        }
        a {
            display: block;
        }
    </style>
</head>
<body>
    <h2>siblings方法()</h2>
    <div class="left first-div">
        <div class="div">
            <ul class="level-1">
                <li class="item-1">1</li>
                <li class="item-2">2</li>
                <li class="item-3">3</li>
            </ul>
        </div>
        <div class="div">
            <ul class="level-2">
                <li class="item-1">1</li>
                <li class="item-2">2</li>
                <li class="item-3">3</li>
            </ul>
        </div>
        <div class="div">
            <ul class="level-3">
                <li class="item-1">1</li>
                <li class="item-2">2</li>
                <li class="item-3">3</li>
            </ul>
        </div>
    </div>
    <button>siblings无参</button>
    <button>siblings传递选择器</button>
</body>
<script>
//jQuery是一个合集对象，所以通过siblings是匹配合集中每一个元素的同辈元素
    $("button:first").click(function () {
        $(".item-2").siblings().css("border",'1px solid red')
    });
    $("button:last").click(function () {
        $(".item-2").siblings(":last").css("border","2px solid blue")
    })

</script>
</html>